package com.zx.zxapibackend.service.impl.inner;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zx.zxapicommon.model.enums.ErrorCode;
import com.zx.zxapicommon.exception.BusinessException;
import com.zx.zxapibackend.service.InterfaceInfoService;
import com.zx.zxapicommon.model.entity.InterfaceInfo;
import com.zx.zxapicommon.service.InnerInterfaceInfoService;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 * @author 张旭
 * @version 1.0
 */
@DubboService
public class InnerInterfaceInfoServiceImpl implements InnerInterfaceInfoService {

    @Resource
    private InterfaceInfoService interfaceInfoService;

    @Override
    public InterfaceInfo getInterfaceInfo(String interfaceId, String url) {
        if (StringUtils.isAnyBlank(interfaceId, url)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数为空");
        }
        QueryWrapper<InterfaceInfo> interfaceInfoQueryWrapper = new QueryWrapper<>();
        interfaceInfoQueryWrapper.eq("id", interfaceId);
        interfaceInfoQueryWrapper.eq("url", url);
        return interfaceInfoService.getOne(interfaceInfoQueryWrapper);

    }
}
